<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>1.localStorage</title>
	</head>
	<body>
		<h1>localStorage</h1>
		<button onclick="savePerson()">向localStorage中存入一个人</button><br/><br/>
		<button onclick="getPerson()">从localStorage中通过key去读取对应的value</button><br/><br/>
		<button onclick="deletePerson()">从localStorage中通过key去删除一组记录</button><br/><br/>
		<button onclick="deleteAll()">清空localStorage</button>

		<script type="text/javascript" >
			let person = {
				name:'圆圆的峰峰',
				age:18,
				gender:'女'
			}

			//存
			function savePerson(){
				localStorage.setItem('ren',JSON.stringify(person))
			}

			//取
			function getPerson(){
				const result = localStorage.getItem('ren')
				console.log(JSON.parse(result))
			}

			//删
			function deletePerson(){
				localStorage.removeItem('ren')
			}

			//删所有
			function deleteAll(){
				localStorage.clear()
			}



		</script>
	</body>
</html>